$RootPath = split-path -parent $MyInvocation.MyCommand.Definition

#Get-Location 返回的不是字符串，返回的是一个对象，所以不能直接赋值，可以通过转换获取到这个值

Write-Host "currentRootPath => $($RootPath)"

push-Location -Path "$($RootPath)/Ocelot.APIGateway"
$currentPath = [string](Get-Location)
Write-Host "*** currentPath => $($currentPath)"
dotnet build 
pop-Location 
#Get-Location
push-Location -Path "$($RootPath)/Order.API"
$currentPath = (Get-Location).Path
Write-Host "*** currentPath => $($currentPath)"
dotnet build 
Pop-Location

push-Location -Path "$($RootPath)/Web.MVC"
$currentPath = (Get-Location).Path
Write-Host "*** currentPath => $($currentPath)"
dotnet build 
Pop-Location

Write-Host "*******"
push-Location -Path "$($RootPath)\Order.API\bin\Debug\netcoreapp3.1\"
$programDllPath = (Get-Location).Path
Write-Host  "dllpath=>$($programDllPath)"

# $processOptions = @{
#     FilePath = $programDllPath
#     UseNewEnvironment = $true
# }

# Start-Process @processOptions
#Start-Process -FilePath "$env:comspec" -ArgumentList "/c dotnet run OrderAPI.dll"
#Start-Process powershell  -ArgumentList "dotnet  OrderAPI.dll", -Wait 
#Start-Process dotnet -ArgumentList "run OrderAPI.dll"

Start-Process powershell -ArgumentList "-NoProfile ", "-NonInteractive", "-NoExit",  {
    dotnet  
}

#Start-Process powershell -ArgumentList "dotnet "   -WorkingDirectory $programDllPath  -Wait


Pop-Location
